package com.example.day08.homework;

import java.util.Scanner;

public class PasswordTest {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int count = 0;
            final String s = scanner.nextLine();
            boolean result = s.length() >= 8;
            count += (s.matches(".*[A-Z]+.*") ? 1 : 0);
            count += (s.matches(".*[a-z]+.*") ? 1 : 0);
            count += (s.matches(".*\\d+.*") ? 1 : 0);
            count += (s.matches(".*[^0-9A-Za-z]+.*") ? 1 : 0);
            result = count >= 3 && result && !s.matches(".*(.{3,}).*\\1.*");
            System.out.println(result ? "OK" : "NO");
        }
    }
}
